package cn.itcast.hotel.controller;

import cn.itcast.hotel.pojo.PageResult;
import cn.itcast.hotel.pojo.RequestParams;
import cn.itcast.hotel.service.IHotelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/hotel")
public class HotelController {

    @Autowired
    private IHotelService iHotelService;

    /**
     * 关键字搜索和分页
     * @param params
     * @return
     */
    @PostMapping("/list")
    public PageResult getPageResult(@RequestBody RequestParams params){
        return iHotelService.getPageResult(params);
    }

    /**
     * 动态获取页面参数
     * @param params
     * @return
     */
    @PostMapping("/filters")
    public Map<String, List<String>> getFilters(@RequestBody RequestParams params){
        return iHotelService.getFilters(params);
    }
    @GetMapping("suggestion")
    public List<String> getSuggestions(String key) {
        return iHotelService.getSuggestions(key);
    }

}
